Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deFile_priv.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deFile_priv.hpp
00003 ///
00004 /// @brief basic file interface header
00005 ///
00006 /// @author Lightning
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date May 2003
00023 /// @author Lightning
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef DE_FILE_PRIV_HPP
00029 #define DE_FILE_PRIV_HPP
00030 
00031 #include "deFileSystem_priv.hpp"
00032 #include "deGlobalTypes.hpp"
00033 #include "deFile.hpp"
00034 #include "dePlugins.hpp"
00035 
00036 //-------------------------------------------
00037 // Classes defined
00038 //-------------------------------------------
00039 class deFile;
00040 class deFileReal;
00041 class deFileVirtual;
00042 class deFilePlugin;
00043 
00044 //-------------------------------------------
00045 // Classes
00046 //-------------------------------------------
00047 
00048 //a class to allow simple usage of the file returned from a file system
00049 class deFile : virtual public IdeFile
00050 {
00051     protected:
00052         deFile();
00053         virtual ~deFile();
00054 
00055     public:
00056 
00057         //close/release the file
00058         int Release();
00059 
00060         //get the interface for a class
00061         void* GetInterface(IdeFile::interface_t i);
00062 
00063         //open a file
00064         virtual deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags);
00065         
00066         //close an open file
00067         virtual deBoolean Close();
00068 
00069         //read/write a file
00070         virtual long Read(void *Buffer, long Length);
00071         virtual long Write(void *Buffer, long Length);
00072 
00073         //get/set file position
00074         virtual long GetPosition();
00075         virtual long SetPosition(long NewPosition, IdeFile::Seek SeekType);
00076 
00077         //get a file's size and set a file's length
00078         virtual long GetSize();
00079         virtual deBoolean SetSize(long NewSize);
00080         
00081         //get/set a file's date/time
00082         virtual s64 GetTime();
00083         virtual deBoolean SetTime(s64 Time);
00084 
00085         //get current file's properties
00086         virtual deBoolean GetProperties(deFileProperties *Properties);
00087 
00088         //get the open flags
00089         virtual long GetOpenFlags();
00090 };
00091 
00092 //class for the memory FS
00093 class deFileMemory : public deFile, public IdeFileMemory
00094 {
00095 public:
00096     deFileMemory();
00097     ~deFileMemory();
00098 
00099     //close/release a file
00100     int Release();
00101 
00102     void* GetInterface(IdeFile::interface_t i);
00103 
00104     //open up a new memory FS, if they tell us a buffer then it is read-only, otherwise
00105     //data is read/write
00106     deBoolean Open();
00107     deBoolean Open(long Length);
00108     deBoolean Open(void *Buffer, long Length);
00109     deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags);
00110     deBoolean Open(IdeFile *BaseFile);
00111 
00112     //close an open file
00113     deBoolean Close();
00114 
00115     //read/write data
00116     long Read(void *Buffer, long Length);
00117     long Write(void *Buffer, long Length);
00118 
00119     //get/set position
00120     long GetPosition();
00121     long SetPosition(long NewPosition, IdeFile::Seek SeekType);
00122 
00123     //get a file's size and set a length
00124     long GetSize();
00125     deBoolean SetSize(long NewSize);
00126 
00127     //get/set a file's date/time
00128     s64 GetTime();
00129     deBoolean SetTime(s64 Time);
00130 
00131     //get current file's properties
00132     deBoolean GetProperties(deFileProperties *Properties);
00133 
00134     //get the open flags
00135     long GetOpenFlags();
00136 
00137 private:
00138     BYTE *      priv_Buffer;        //pointer to the data
00139     deBoolean   priv_OwnBuffer;     //do we own the buffer
00140     long        priv_AllocSize;     //current size of the memory
00141     long        priv_KnownSize;     //the known size for the memory (returned on GetSize)
00142     long        priv_NewAllocSize;  //size of a new chunk to alloc if needed
00143     long        priv_Position;      //the current position in the memory pool
00144 
00145     IdeFile *       priv_BaseFile;      //base file that is open
00146     IdeFileSystem * priv_BaseFS;        //base fs that a file was opened from
00147     long            priv_OpenFlags;     //flags about the file/data
00148 };
00149 
00150 //class for the virtual file
00151 class deFileVirtual : virtual public deFile, public IdeFileVirtual
00152 {
00153 protected:
00154     deFileVirtual();
00155 
00156     deFSVirtual *                       priv_BaseFS;
00157     deFSVirtual::VirtualFileEntry *     priv_CurrentFile;
00158 
00159     //various properties to store in the file class
00160     long            priv_FileFlags;
00161     long            priv_CurrentPosition;
00162 
00163     friend class deFSVirtual;
00164 
00165 public:
00166     ~deFileVirtual();
00167 
00168     //close/release a file
00169     int Release();
00170 
00171     void* GetInterface(IdeFile::interface_t i);
00172 
00173     //open a file
00174     deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags);
00175 
00176     //close an open file
00177     deBoolean Close();
00178 
00179     //read/write data
00180     long Read(void *Buffer, long Length);
00181     long Write(void *Buffer, long Length);
00182 
00183     //get/set position
00184     long GetPosition();
00185     long SetPosition(long NewPosition, IdeFile::Seek SeekType);
00186 
00187     //get a file's size and set a length
00188     long GetSize();
00189     deBoolean SetSize(long NewSize);
00190     DWORD SetSize(long NewSize, deFSPROGRESS *StatusCallback);
00191 
00192     //get/set a file's date/time
00193     s64 GetTime();
00194     deBoolean SetTime(s64 Time);
00195 
00196     //get current file's properties
00197     deBoolean GetProperties(deFileProperties *Properties);
00198 
00199     //get the open flags
00200     long GetOpenFlags();
00201 };
00202 
00203 //class for the real file
00204 class deFileReal : virtual public deFile, public IdeFileReal
00205 {
00206 protected:
00207     deFileReal();
00208 
00209 #ifdef _WIN32
00210   HANDLE        priv_FileHandle;                    //handle to the open file
00211 #elif linux
00212   int               priv_FileHandle;
00213   char            priv_FilePath[256];
00214 #else
00215 #error("File Handle not supported for OS");
00216 #endif
00217 
00218     long        priv_OpenFlags;                     //flags used on open
00219     char        priv_Filename[256];                 //filename of the current file  
00220 
00221     friend class deFSReal;
00222 
00223 public:
00224     ~deFileReal();
00225 
00226     //close/release a file
00227     int Release();
00228 
00229     void* GetInterface(IdeFile::interface_t i);
00230     
00231     //open a file
00232     deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags);
00233 
00234     //close an open file
00235     deBoolean Close();
00236 
00237     //read/write data
00238     long Read(void *Buffer, long Length);
00239     long Write(void *Buffer, long Length);
00240 
00241     //get/set position
00242     long GetPosition();
00243     long SetPosition(long NewPosition, IdeFile::Seek SeekType);
00244 
00245     //get a file's size and set a length
00246     long GetSize();
00247     deBoolean SetSize(long NewSize);
00248 
00249     //get/set a file's date/time
00250     s64 GetTime();
00251     deBoolean SetTime(s64 Time);
00252 
00253     //get current file's properties
00254     deBoolean GetProperties(deFileProperties *Properties);
00255 
00256     //get the open flags
00257     long GetOpenFlags();
00258 };
00259 
00260 //class for the plugin file
00261 class deFilePlugin : virtual public deFile, public IdeFilePlugin
00262 {
00263 public:
00264     deFilePlugin();
00265     ~deFilePlugin();
00266 
00267     //close/release a file
00268     int Release();
00269 
00270     void* GetInterface(IdeFile::interface_t i);
00271     
00272     //open a file
00273     deBoolean Open(IdeFileSystem *BaseFS, char *Filename, long OpenFlags);
00274     deBoolean Open(IdeFile *BaseFile);
00275     
00276     //close an open file
00277     deBoolean Close();
00278 
00279     //read/write data
00280     long Read(void *Buffer, long Length);
00281     long Write(void *Buffer, long Length);
00282 
00283     //get/set position
00284     long GetPosition();
00285     long SetPosition(long NewPosition, IdeFile::Seek SeekType);
00286 
00287     //get a file's size and set a length
00288     long GetSize();
00289     deBoolean SetSize(long NewSize);
00290 
00291     //get/set a file's date/time
00292     s64 GetTime();
00293     deBoolean SetTime(s64 Time);
00294 
00295     //get current file's properties
00296     deBoolean GetProperties(deFileProperties *Properties);
00297 
00298     //get the open flags
00299     long GetOpenFlags();
00300 
00301     deBoolean AddPlugin(IdePlugin *Plugin);
00302     deBoolean ReleasePlugin(IdePlugin *Plugin);
00303     deBoolean ReleaseAllPlugins();
00304 
00305     //order all the blocks in the file
00306     deBoolean DefragFile();
00307 
00308 private:
00309     IdeFile *       priv_BaseFile;          //base file we are attached to
00310     IdeFileSystem * priv_BaseFS;            //basefs if any to let go of
00311     deBoolean       priv_OwnBaseFile;       //do we own the base file
00312     long            priv_CurrentPosition;   //current position in the file
00313     long            priv_OpenFlags;         //open flags for files
00314 
00315     //a linked list for the plugins
00316     typedef struct PluginList
00317     {
00318         IdePlugin *             Plugin;     //attached plugin
00319         struct PluginList *     Next;       //next plugin in the list
00320         struct PluginList *     Previous;   //previous plugin in the list
00321     } PluginList;
00322 
00323     //header data about the file
00324 #pragma pack(1)
00325     typedef struct PluginHeader
00326     {
00327         DWORD       ID;             //ID of the file
00328         DWORD       Version;        //version ID
00329         long        DataOffset;     //position of PluginFileData entries
00330         long        LastBlockSize;  //original size of the last block's data
00331         short       EntryCount;     //number of entries
00332     } PluginHeader;
00333 #pragma pack()
00334 
00335     //data about the file
00336     typedef struct PluginFileData
00337     {
00338         long        RealFilePos;    //real position the block is at
00339         long        Size;           //size of the data block
00340     } PluginFileData;
00341 
00342     //function for getting a block of data from a file
00343     deBoolean GetFileBlock(long ReadBlock);
00344     deBoolean WriteCurrentFileBlock();
00345 
00346     //functions to apply plugins to data
00347     void *ApplyPluginEncode(void *Buffer, long *Length);
00348     void *ApplyPluginDecode(void *Buffer, long *Length);
00349 
00350     PluginList *    priv_PluginList_First;  //first entry in the list of plugins for the file
00351     PluginList *    priv_PluginList_Last;   //last entry in the list of plugins for the file
00352     deBoolean       priv_PluginLocked;      //whether or not plugins can be updated 
00353 
00354     //info about the file itself
00355     PluginFileData *    priv_FileData;          //array of file data information
00356     short               priv_FileDataCount;     //number of entries in the array
00357     long                priv_LastBlockSize;     //size of the last block's data
00358     
00359     deBoolean           priv_FileBlockChanged;  //data in the block was changed
00360     void *              priv_FileBuffer;        //buffer of file data
00361     long                priv_FileBlock;         //current block that the buffer is from
00362 };
00363 
00364 #endif
00365 

Generated on Mon Sep 12 19:58:26 2005 for Destiny3D by doxygen1.3-rc3